package ast;

import java.util.*;

import lexer.Symbol;

public class InstanceVariableList {

	public InstanceVariableList() {
		instanceVariableList = new ArrayList<InstanceVariable>();
	}

	public void addElement(InstanceVariable instanceVariable) {
		instanceVariableList.add(instanceVariable);
	}

	public Iterator<InstanceVariable> elements() {
		return this.instanceVariableList.iterator();
	}

	public int getSize() {
		return instanceVariableList.size();
	}

	public ArrayList<InstanceVariable> getInstanceVariableList() {
		return instanceVariableList;
	}

	public void setInstanceVariableList(
			ArrayList<InstanceVariable> instanceVariableList) {
		this.instanceVariableList = instanceVariableList;
	}

	public void genKrakatoa(PW pw) {
		Type type;

		for (int i = 0; i < instanceVariableList.size(); i++) {
			switch (instanceVariableList.get(i).qualifier) {
			case Symbol.PRIVATE:
				pw.printIdent("private ");
				break;
			case Symbol.PUBLIC:
				pw.printIdent("public ");
				break;
			case Symbol.STATICPRIVATE:
				pw.printIdent("static private ");
				break;
			case Symbol.STATICPUBLIC:
				pw.printIdent("static public ");
				break;
			}
			type = instanceVariableList.get(i).getType();
			pw.print(type.getKrakatoaName() + " ");
			instanceVariableList.get(i).genKrakatoa(pw);
			pw.print(";\n");
		}

	}

	private ArrayList<InstanceVariable> instanceVariableList;

}
